
ac.buff('击飞'){

    displace = true,

    debuff = true,
    
    maxheight = 1024,   --- 最高叠加到的高度
    control = true,
    level = 1,
    
    height = 512,       --- 击飞高度
    time = 1.00,        --- 击飞时间

    pulse = 0.03,
    physics = true,     --- 物理Buff

    stun_flag = true,

    on_add = function(self)
        local unit = self.owner
        if self:get_remaining() <= 0 then 
            self:remove()
            return false 
        end
        self.default = unit:get_default_height()
        self.current = unit:get_height()
        self.point = unit:get_point()
        self.highest = (self.height + self.current) / (1 + (self.height + self.current) / self.maxheight)
        self.length = (self.height + self.highest - self.default)
        if self.length <= 0 then 
            self:remove()
            return false
        end
        self.speed = self.length / self.time
        self.progress = 0.0
        self.moved = 0.0
        self.has_unmove = true
        self.has_resume = true
        self.has_launch = true
        unit:notify("单位-打断位移", unit)
        unit:add_restriction "位移"
        unit:add_restriction "幽灵"
        if self.stun_flag then 
            self.has_stun = true
            unit:add_restriction "晕眩"
        end
        self.trigger = unit:on "单位-打断位移" (function (_, _, flag)
            self.has_resume = (flag == true) 
            self:notify("on_break")
            self:remove()
        end)
        self:notify("on_launch")
    end,

    on_pulse = function(self)
        local unit = self.owner 
        self.moved = self.moved + self.speed * self.pulse
        self.progress = self.moved / self.length 
        unit:set_height( math.parabola(self.current, self.highest, self.default, self.progress) )
    end,

    on_remove = function(self)
        local unit = self.owner 
        if self.has_unmove then 
            unit:remove_restriction "位移"
            unit:remove_restriction "幽灵"
            if self.has_stun then 
                unit:remove_restriction "晕眩"
            end
        end
        if self.has_resume then 
            unit:set_height( unit:get_default_height() )
        end 
        if self.trigger then 
            self.trigger:remove()
        end
        if self.has_launch then 
            self:notify("on_stop")
        end 
    end,

    on_cover = function(self, new)
        local time = self:get_remaining()
        if new.time < time then 
            new.time = time
        end 
        new.maxheight = math.max(self.maxheight, new.maxheight)
        self.has_resume = false
        return true
    end,
}

